package com.gome.han.beencloud.netty._01_Discard_Server;


/**
 * @author hanpeng
 * @version 创建时间：2020年9月2日 下午4:33:36
 * @ClassName 类名称
 * @Description 类描述
 */
/*public class DiscardServer {
	//static final boolean SSL = System.getProperty("ssl") != null;
	static final boolean SSL = false;
	static final int PORT = 8088;

	public static void main(String[] args) throws Exception {
		// Configure SSL.
		final SslContext sslCtx;
		if (SSL) {
			SelfSignedCertificate ssc = new SelfSignedCertificate();
			sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
		} else {
			sslCtx = null;
		}

		EventLoopGroup bossGroup = new NioEventLoopGroup(1);
		EventLoopGroup workerGroup = new NioEventLoopGroup();
		try {
			ServerBootstrap b = new ServerBootstrap();
			b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
					.handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {
						@SuppressWarnings("unused")
						@Override
						public void initChannel(SocketChannel ch) {
							ChannelPipeline p = ch.pipeline();
							if (sslCtx != null) {
								p.addLast(sslCtx.newHandler(ch.alloc()));
							}
							p.addLast(new DiscardServerHandler());
						}
					});

			// Bind and start to accept incoming connections.
			ChannelFuture f = b.bind(PORT).sync();

			// Wait until the server socket is closed.
			// In this example, this does not happen, but you can do that to gracefully
			// shut down your server.
			f.channel().closeFuture().sync();
		} finally {
			workerGroup.shutdownGracefully();
			bossGroup.shutdownGracefully();
		}
	}
}*/
